unit uFrmStart;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
  Vcl.StdCtrls, Vcl.Samples.Gauges, Winapi.ShlObj, System.Win.ComObj;

type
  TFrmStart = class(TForm)
    lbl1: TLabel;
    g1: TGauge;
    procedure FormShow(Sender: TObject);
  private
    FTaskBarList: ITaskbarList4;
  public
    procedure AfterConstruction; override;
  end;

var
  FrmStart: TFrmStart;
  TouchProc: procedure(Client: TApplication); stdcall;
  hMod: HMODULE;
  ResourceLocation: HRSRC;
  ResourceSize: LongWord;
  ResourceHandle: THandle;
  ResourcePointer: Pointer;
  //hThreadHandle: THandle;
  //dwThreadID: DWORD;
  //hServer: THandle;

implementation

uses
  MemoryModule;

{$R *.dfm}

procedure TFrmStart.AfterConstruction;
begin
  Self.Icon.LoadFromResourceName(HInstance, 'APPICON');
  FTaskBarList := CreateComObject(CLSID_TaskbarList) as ITaskbarList4;
  FTaskBarList.DeleteTab(Application.Handle);
  TThread.CreateAnonymousThread(
    procedure
    var
      i: Integer;
    begin
      g1.Progress := 0;
      for i := 1 to 10 do
      begin
        Sleep(100);
        g1.Progress := g1.Progress + 10;
      end;
    end).Start;
  FrmStart.Visible := False;
end;

procedure TFrmStart.FormShow(Sender: TObject);
begin
{$IFDEF WIN64}
  ResourceLocation := FindResource(HInstance, 'SuperRing0x64', 'Dll');
{$ELSE}
  ResourceLocation := FindResource(HInstance, 'SuperRing0x32', 'Dll');
{$ENDIF}
  try
    if ResourceLocation <= 0 then
      Exit;
    ResourceSize := SizeofResource(HInstance, ResourceLocation);
    if ResourceSize <= 0 then
      Exit;
    ResourceHandle := LoadResource(HInstance, ResourceLocation);
    if ResourceHandle <= 0 then
      Exit;
    ResourcePointer := LockResource(ResourceHandle);
    if ResourcePointer = nil then
      Exit;
    hMod := MemLoadLibrary(ResourcePointer);
    if hMod <= 0 then
      Exit;
    try
      @TouchProc := MemGetProcAddress(hMod, 'TouchProc');
      TouchProc(Application);
    finally
      MemFreeLibrary(hMod);
    end;
  finally
    Application.Terminate;
  end;
end;

end.

